package com.zsh.mvc.controller;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @author zsh
 * @Description
 * @create 2022-01-27 18:54
 */

@ControllerAdvice
public class ExceptionController {

    //@ExceptionHandler用于设置所标识方法处理的异常
    @ExceptionHandler(value = {ArithmeticException.class,NullPointerException.class})
    public String testException2(Exception ex, Model model){
        model.addAttribute("ex", ex);
        return "error";
    }

}
